from numpy import random
import matplotlib.pyplot as plt
import seaborn as sns
#Uniform
x = random.uniform(size=(2, 3))
print(x)
sns.kdeplot(random.uniform(size=1000), fill=False)
plt.title('uniform')
plt.show()
#Normal
'''
loc - (Mean) where the peak of the bell exists.
scale - (Standard Deviation) how flat the graph distribution should be.
size - The shape of the returned array.
'''
x = random.normal(size=(2, 3))
print(x)
x = random.normal(loc=1, scale=2, size=(2, 3))
print(x)
sns.kdeplot(random.normal(size=1000), fill=False)
plt.title('normal')
plt.show()
#Binomial Distribution
'''
Binomial Distribution is a Discrete Distribution.
It describes the outcome of binary scenarios, e.g. toss of a coin, it will either be head or tails.
It has three parameters:
n - number of trials.
p - probability of occurence of each trial (e.g. for toss of a coin 0.5 each).
size - The shape of the returned array.
'''
x = random.binomial(n=10, p=0.5, size=10)
print(x)
sns.histplot(random.binomial(n=10, p=0.5, size=1000), kde=False)
plt.title('binomial')
plt.show()

## normal vs binomial
sns.kdeplot(random.normal(loc=50, scale=5, size=1000), label='normal')
sns.kdeplot(random.binomial(n=100, p=0.5, size=1000), label='binomial')
plt.title("normal vs binomial")
plt.legend()  # 这里会使用前面提供的标签
plt.show()

#Poisson Distribution
'''
Poisson Distribution is a Discrete Distribution.
It estimates how many times an event can happen in a specified time. e.g. If someone eats twice a day what is the probability he will eat thrice?
It has two parameters:
lam - rate or known number of occurrences e.g. 2 for above problem.
size - The shape of the returned array.
'''
x = random.poisson(lam=2, size=10)
print(x)
sns.histplot(random.poisson(lam=2, size=1000), kde=False)
plt.title('poisson')
plt.show()

## Normal vs Poisson
sns.kdeplot(random.normal(loc=50, scale=7, size=1000),  label='normal')
sns.kdeplot(random.poisson(lam=50, size=1000),  label='poisson')
plt.title('normal vs poisson')
plt.legend()  # 这里会使用前面提供的标签
plt.show()

## Binomial vs Poisson
sns.kdeplot(random.binomial(n=1000,p=0.01, size=1000),  label='binomial')
sns.kdeplot(random.poisson(lam=10, size=1000),  label='poisson')
plt.title('Binomial vs Poisson')
plt.legend()  # 这里会使用前面提供的标签
plt.show()

#Logistic Distribution
'''
Logistic Distribution is used to describe growth.
Used extensively in machine learning in logistic regression, neural networks etc.
It has three parameters:
loc - mean, where the peak is. Default 0.
scale - standard deviation, the flatness of distribution. Default 1.
size - The shape of the returned array
'''
x = random.logistic(loc=1, scale=2, size=(2, 3))
print(x)
sns.kdeplot(random.logistic(size=1000))
plt.title('logistic')
plt.show()
## Logistic vs Normal
sns.kdeplot(random.normal(scale=2, size=1000),  label='normal')
sns.kdeplot(random.logistic( size=1000),  label='logistic')
plt.title(' Logistic vs Normal')
plt.legend()  # 这里会使用前面提供的标签
plt.show()
#Multinomial Distribution
'''
Multinomial distribution is a generalization of binomial distribution.
It describes outcomes of multi-nomial scenarios unlike binomial where scenarios must be only one of two. e.g. Blood type of a population, dice roll outcome.
It has three parameters:
n - number of possible outcomes (e.g. 6 for dice roll).
pvals - list of probabilties of outcomes (e.g. [1/6, 1/6, 1/6, 1/6, 1/6, 1/6] for dice roll).
size - The shape of the returned array.
'''
x = random.multinomial(n=6, pvals=[1/6, 1/6, 1/6, 1/6, 1/6, 1/6])
print(x)
# Exponential Distribution
'''
Exponential distribution is used for describing time till next event e.g. failure/success etc.
It has two parameters:
scale - inverse of rate ( see lam in poisson distribution ) defaults to 1.0.
size - The shape of the returned array.
'''
x = random.exponential(scale=2, size=(2, 3))
print(x)
sns.kdeplot(random.exponential(size=1000))
plt.title('exponential')
plt.show()

#Chi Square Distribution
'''
Chi Square distribution is used as a basis to verify the hypothesis.
It has two parameters:
df - (degree of freedom).
size - The shape of the returned array.
'''
x = random.chisquare(df=2, size=(2, 3))
print(x)
sns.kdeplot(random.chisquare(df=1, size=1000))
plt.title('chisquare')
plt.show()
#Rayleigh Distribution
'''
Rayleigh distribution is used in signal processing.
It has two parameters:
scale - (standard deviation) decides how flat the distribution will be default 1.0).
size - The shape of the returned array.
'''
x = random.rayleigh(scale=2, size=(2, 3))
print(x)
sns.kdeplot(random.rayleigh(size=1000))
plt.title('rayleigh')
plt.show()

#Pareto Distribution
'''
A distribution following Pareto's law i.e. 80-20 distribution (20% factors cause 80% outcome).
It has two parameter:
a - shape parameter.
size - The shape of the returned array.
'''
x = random.pareto(a=2, size=(2, 3))
print(x)
sns.histplot(random.pareto(a=2, size=1000), kde=False)
plt.title('pareto')
plt.show()
#Zipf Distribution
'''
Zipf distributions are used to sample data based on zipf's law.
Zipf's Law: In a collection, the nth common term is 1/n times of the most common term. E.g. the 5th most common word in English occurs nearly 1/5 times as often as the most common word.
It has two parameters:
a - distribution parameter.
size - The shape of the returned array.
'''
x = random.zipf(a=2, size=(2, 3))
print(x)
x = random.zipf(a=2, size=1000)
sns.histplot(x[x<10], kde=False)
plt.title('zipf')
plt.show()